package com.sykj.bsc.hyx.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sykj.bsc.hyx.bean.Bis_opinion;
import com.sykj.bsc.hyx.service.Bis_opinionService;
import com.sykj.bsc.rwl.po.extend.SysUserExtend;
import com.sykj.bsc.util.Tools;

@Controller
@RequestMapping("Bis_opinion")
public class bis_opinionController {
	@Autowired
	public Bis_opinionService bis_opinionService;
	//显示意见
	@RequestMapping("selectBis_opinion")
	public String selectBis_opinion(Model model,HttpServletRequest request,@RequestParam(value="page",defaultValue="1")int page){
		Map map=initMap(request);
		PageHelper.startPage(page, 5);
	    List<Bis_opinion>selectBis_opinion=bis_opinionService.selectBis_opinion(map);
	    PageInfo<Bis_opinion> pageInfo=new PageInfo<Bis_opinion>(selectBis_opinion);
	    model.addAttribute("selectBis_opinion", selectBis_opinion);
	    model.addAttribute("p", pageInfo);
		return "backstage/hyx/selectBis_opinion";
	}
	//查询意见
	public Map initMap(HttpServletRequest request){
		Map<String,Object> map=new HashMap<String,Object>();
		String opinion_id=request.getParameter("opinion_id");//手机号
		String content=request.getParameter("content");//内容
		String create_time1=request.getParameter("create_time1");//发起时间1
		String create_time2=request.getParameter("create_time2");//发起时间2
		System.out.println("opinion_id:"+opinion_id);
		if(Tools.isNotNull(opinion_id)){
			map.put("opinion_id", opinion_id);
			request.setAttribute("opinion_id",opinion_id);
		}
		if(Tools.isNotNull(content)){
			map.put("content",content );
			request.setAttribute("content",content);
		}
		if(Tools.isNotNull(create_time1)){
			map.put("create_time1",create_time1 );
			request.setAttribute("create_time1",create_time1);
		}
		if(Tools.isNotNull(create_time2)){
			map.put("create_time2",create_time2 );
			request.setAttribute("create_time2",create_time2);
		}
		return map;
	}
	
	//全选删除和单选删除
	@RequestMapping("delete")
	public String datele(String ids){
		bis_opinionService.delete(ids);//取循环值
		return "redirect:/Bis_opinion/selectBis_opinion";
	}
	//查看详情
	@RequestMapping("select")
	@ResponseBody
	public Bis_opinion select6(String opinion_id,Model model){
		Bis_opinion op=this.bis_opinionService.getById(Integer.valueOf(opinion_id));
		return op;
	}
}
